﻿
@using SmartSiteManagementSystem.Models.User;
@using SmartSiteManagementSystem.IServices;
@{
    Layout = "~/Views/Shared/_Layout.cshtml";
    ViewBag.BodyClass = "easyui-layout";
    UserHealthMonitorInfo userHealthMonitorInfo = ViewBag.userHealthMonitorInfo;
}
    <div class="easyui-panel" style="padding:5px;">    
        <input id="LogId" type="hidden" value="@userHealthMonitorInfo.LogId" />
        <table class="gou-formTable" style="align-content:center;">
            <tbody>   
                
                <tr>
                    <td align="right" class="gou-formTable-title" style="width:160px;">*用户:</td>
                    <td align="left" class="">
                <select  id="combo_selUser" name="combo_selUser" class="easyui-combobox" style="width:150px;">
                
                <option value="-1">请选择</option>
                  @foreach (var item in ViewBag.userList as IList<UserInfo>)
                {

                    <option value="@item.UserId"> @(item.ShowName) </option>
                }

            </select> 
                    </td>
                </tr>

                <tr>
                    <td align="right" class="gou-formTable-title" style="width:160px;">*心跳:</td>
                    <td align="left" class="">
                         <input id="HeartBeat" name="HeartBeat" type="text" value="@userHealthMonitorInfo.HeartBeat" />    
                    </td>
                </tr>
                         <tr>
                    <td align="right" class="gou-formTable-title" style="width:160px;">*体温:</td>
                    <td align="left" class="">
                         <input id="Temperature" name="Temperature" type="text" value="@userHealthMonitorInfo.Temperature" />    
                    </td>
                </tr>



                               <tr>
                    <td align="right" class="gou-formTable-title" style="width:160px;">*采集时间:</td>
                    <td align="left" class="">
                  
                <input id="CollectTime" name="CollectTime" class="easyui-datetimebox" value="@userHealthMonitorInfo.CollectTime">
        
                    </td>
                </tr>  

                 

                <tr>
                    <td colspan="2" align="center">                       
                            <a href="javascript:void(0)" id="hfSave" class="easyui-linkbutton" iconcls="icon-save" onclick="Save();" style="width:150px;height:32px">保存</a>                                           
                    </td>
                </tr>
            </tbody>
        </table>

    </div>



    <script type="text/javascript">        

            $(document).ready(function(){
        @if(userHealthMonitorInfo.LogId>0){
        <text>
             $('#combo_selUser').combobox('setValue',@(userHealthMonitorInfo.UserId) );
        </text>
          }
     });


        //保存
        function Save() {

            //验证必选项******************************************************************
            var selUserId = $("[name=combo_selUser]").val();
            if (selUserId == "-1") {
                $.messager.alert('提示', '请选择用户!');
                return false;
            }
        
            var LogId = $("#LogId").val();
            var HeartBeat= $("#HeartBeat").val();
            var Temperature=$("#Temperature").val();
         
            var CollectTime = $("input[name=CollectTime]").val();
           
            
           if (CollectTime == "" ) {
                $.messager.alert('提示', '请选择采集时间!');
                return false;
            }
            
            var param = { LogId: LogId, UserId: selUserId,HeartBeat: HeartBeat,Temperature: Temperature,CollectTime:CollectTime};
            $.ajax({
                "type": "Post",
                "url": "ajaxHealthMonitorAccess?t=" + new Date().getTime(),
                "dataType": "json",
                "data": param,
                "success": function (data) {
                    if (data.IsSuccess) {
                        window.location.href = "HealthMonitorIndex";
                    }
                    else
                    {
                        $.messager.alert('提示', data.Msg);
                    }
                }
            });
        }
</script>    
